#include <cstdio>
#include <algorithm>
#include <cstring>
using namespace std;
const int N=15;
bool ac[N];
int wa[N];
int main(void){
    int t;
    int n,m;
    int id,ho,mi;
    char st[5];
    scanf("%d",&t);
    while(t--){
        memset(ac,false,sizeof(ac));
        memset(wa,0,sizeof(wa));
        int cnt=0;
        int ans=0;
        scanf("%d%d",&n,&m);
        while(m--){
            scanf("%d %d:%d %s",&id,&ho,&mi,st);
            //printf("%d %d %d %s\n",id,ho,mi,st);
            if(ac[id-1000]){
                continue;
            }
            else{
                if(strcmp(st,"AC")==0){
                    ac[id-1000]=true;
                    cnt++;
                    ans+=(wa[id-1000]+ho*60+mi);
                }
                else{
                    wa[id-1000]+=20;
                }
            }
        }
        printf("%d %d\n",cnt,ans);
    }
    return 0;
}